package com.demo.delivery.utils;

import android.app.Application;

public class AppUtils {

    private static Application application;

    /**
     * 反射获取Application对象
     */
    public static Application getApplication() {
        if (application == null) {
            try {
                application = (Application) Class.forName("android.app.ActivityThread")
                        .getMethod("currentApplication")
                        .invoke(null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return application;
    }
}
